{include file='pub/header'/}
<title>新增分类</title>
</head>
<body>
<div class="page-container">
    <form class="form form-horizontal" id="form-category-add">
        <input type="hidden" name="parent_id" value="{$pid}"/>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">排序值：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="50" placeholder="" id="orderid" name="ord">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">分类图标：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="uploader-thum-container">
                    <div id="fileList" class="uploader-list">
                    </div>
                    <div id="filePicker">选择图片</div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">分类文字图标：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="uploader-thum-container">
                    <div id="fileList1" class="uploader-list">
                    </div>
                    <div id="filePicker1">选择图片</div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">导航是否显示：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="uploader-thum-container">
                    <label for=""><input type="radio" value="1" class="check-box" placeholder="" name="is_index">是</label>
                    <label for=""><input type="radio" value="0" class="check-box" checked placeholder="" name="is_index">否</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">首页推荐：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <label for=""><input type="radio" value="1" class="check-box" placeholder="" name="is_recommond">是</label>
                <label for=""><input type="radio" value="0" class="check-box" placeholder="" checked name="is_recommond">否</label>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">推荐商品数量：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" value="8" placeholder="" name="show_num">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存分类
                </button>
                <button onClick="layer_close();" class="btn btn-default radius" type="button">
                    &nbsp;&nbsp;取消&nbsp;&nbsp;
                </button>
            </div>
        </div>
    </form>
</div>


{include file="pub/footer"/}
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        uploadImage($("#fileList"), null, $("#form-category-add"), "image");
        uploadImage($("#fileList1"), null, $("#form-category-add"), "word_image", "#filePicker1", 1);
        $("#form-category-add").validate({
            rules: {
                name: {
                    required: true
                }
            },
            messages: {
                name: {
                    required: '分类名称不能为空'
                }
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    type: 'post',
                    url: '{:url("Category/categoryAdd")}',
                    success: function (res) {
                        if (1 == res.code) {
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg(res.msg, {icon: 6, time: 1000});
                            setTimeout(function () {
                                parent.location.reload();
                                parent.layer.close(index);
                            }, 1000);
                        } else {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>